<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use think\Request;
use think\facade\Session;
class Base extends Controller
{
     public function upaction($file){
    	// return Env::get('root_path');
	     // foreach($files as $file){
		    //上传回调error为0
		    
		    if(empty($file)){
		        $result["error"] = "1";
		        $result['data'] = '';
		    }else{
		        // 移动到框架应用根目录/public/uploads/ 目录下
		        $rpath=Env::get('root_path');
		        $info = $file->move($rpath . 'public/static/uploads' );
		        if($info){
		            $name_path =$info->getSaveName();
		            //成功上传后 获取上传信息
		            $name_path =str_replace('\\',"/",$info->getSaveName());
		            $result["error"] = '0';
		            $result['data'] = "/static/uploads/".$name_path;
		        }else{
		            // 上传失败获取错误信息
		            $result["code"] = "2";
		            $result['data'] ='';
		        }
		    }
	      exit(json_encode($result));
	      
	     // }
    }

}
